<template>
  <div id="app">
    <router-view class="main" />
    <!-- //加上这个属性之后，就可以让每一个子节点当路由组件使用 -->
    <van-tabbar
      inactive-color="rgb(189, 153, 220)"
      active-color="deeppink"
      :fixed="false"
      route
      v-show="isShowTabBar"
    >
      <van-tabbar-item icon="home-o" :to="{ name: 'Home' }">首页</van-tabbar-item>
      <van-tabbar-item icon="shop-o" :to="{ name: 'List' }">热卖</van-tabbar-item>
      <van-tabbar-item icon="shopping-cart-o" badge="7" :to="{ name: 'Cart' }"
        >购物车</van-tabbar-item
      >
      <van-tabbar-item icon="user-o" :to="{ name: 'User' }">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>
<script>
export default {
  data() {
    return {
      isShowTabBar: true,
    };
  },
  watch: {
    $route(v) {
      if (v.meta.hideTabBar) {
        this.isShowTabBar = false;
      } else {
        this.isShowTabBar = true;
      }
    },
  },
};
</script>
<style>
html,
body {
  width: 100%;
  height: 100%;
}
#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.main {
  flex: 1;
  overflow: auto;
}
</style>
